import React, { Component } from 'react';
import {
    View,
    ListView,
} from 'react-native';


import { mapcarStyle as styles } from '../../../styles';
import Mapcolor from './carcolor';
var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
export default class Car_list extends Component {
    // 初始化模拟数据
    constructor(props) {
        super(props);
    }
    render() {
        this.state = {
            dataSource: ds.cloneWithRows(this.props.Lines)
        };
        return (
            <View style={styles.carlistin}>
                <ListView
                    enableEmptySections={true}
                    dataSource={this.state.dataSource}
                    renderRow={this.renderRow.bind(this)}
                    onEndReachedThreshold={1}
                    horizontal={true}
                    contentContainerStyle={styles.mapcarlist}
                    showsHorizontalScrollIndicator={false}
                />
            </View>
        );
    }



    renderRow(rowData) {
        return (
            <Mapcolor data={rowData} selected={rowData.index==this.props.theLine?true:false} callBack={this.props.callBack}/>
        )
    }
}